import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * This class makes reference to the main menu on the game.
 * 
 * @author (Arturo Aaron Rios Obregon) 
 * @version (2 july 2013)
 */
public class Menu extends World
{
    private Start b1;
    private Help b2;
    private Records b3;
    private Credits b4;
    private GreenfootSound s;
    
    /**
     * Constructor for objects of class Menu.
     * 
     */
    public Menu()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(600, 400, 1); 
        b1 = new Start();
        addObject(b1,100,300);
        b2 = new Help();
        addObject(b2,220,270);
        b3 = new Records();
        addObject(b3,340,240);
        b4 = new Credits();
        addObject(b4,460,210);
        s = new GreenfootSound("menusound.mp3");
    }
    
    /**
     * Its the act method that check which button was touched.
     */
    public void act()
    {
        MouseInfo m = Greenfoot.getMouseInfo();
        if(!s.isPlaying())
            s.play();
        
        if(Greenfoot.mousePressed(b1))
         {
             s.stop();
             Greenfoot.setWorld(new Juego());
         }
        if(Greenfoot.mousePressed(b2))
         {          
             s.stop();
             Greenfoot.setWorld(new HelpWindow());
         }
        if(Greenfoot.mousePressed(b3))
         {            
             s.stop();
             Greenfoot.setWorld(new RecordsWindow());
         } 
        if(Greenfoot.mousePressed(b4))
         {             
             s.stop();
             Greenfoot.setWorld(new CreditsWindow());          
         } 
    }
    
    /**
    * When the execution of the program stop the music stop too.
    */
    public void stopped()
    {
        s.pause();
    }
    
    /**
     * When the execution of the program is reanuded the music reanuded too.
     */
    public void started()
    {
        s.play();
    }
}
